C# implementation
